from django.db.models import *
from os import path
from base import BaseModel

class XMLFile(Model):
    """\
    This class represents a file in the original ftb bundle.
    It stores only the file name. For performances reasons, the file content is stored in XMLContent.
    """
    name = CharField(max_length=100, unique=True)
    def __unicode__(self):
        return self.name

    def number_of_sentences(self):
        return self.sentence_set.count()
    
    class Meta:
        app_label = 'core'


class XMLContent(Model):
    """\
    This is the class that stores xml file contents.
    """
    content = XMLField(schema_path=path.join(settings.ROOT, "core", "Paris7treebank.rng"))
    file = OneToOneField('XMLFile')    

    class Meta:
        app_label = 'core'